import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *

class Menu(QMainWindow):
    def __init__(self):
        super().__init__()
        bar=self.menuBar()#获取菜单栏

        file=bar.addMenu("文件")
        file.addAction("新建")

        save=QAction("保存",self)
        save.setShortcut("Ctrl+S")
        file.addAction(save)
        save.triggered.connect(self.process)

        edit=bar.addMenu("Edit")
        edit.addAction("copy")
        edit.addAction("paste")
        quit=QAction("退出",self)
        file.addAction(quit)

    def process(self,a):
        print(self.sender().text())


if __name__ == '__main__':
    app=QApplication(sys.argv)
    my=Menu()
    my.show()
    sys.exit(app.exec_())